<template>
    <div>
        <el-row>
            <el-col :span="24">
                <div>
                    <el-button type="primary" @click="addBtn">开票</el-button>

                    <!-- 点击触发文件选择的导入按钮 -->
                    <el-button plain>导入</el-button>

                    <el-button plain>导出</el-button>

                    <el-button plain>打印</el-button>
                </div>
            </el-col>
        </el-row>
        <br>
        <el-row>
            <el-col :span="24">
                <el-form :inline="true" :model="param">



                    <el-form-item label="" label-width="100px">
                        <el-input placeholder="请输入订单号或流水号搜索" style="width: 200px; margin-left: 10px;"
                            v-model="param.departmentName">
                        </el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button type="primary" @click="queryAll">查询</el-button>
                        <el-button style="margin-left: 10px;" @click="clearSearch">重置</el-button>
                    </el-form-item>

                </el-form>
            </el-col>
        </el-row>

        <el-row>
            <el-col :span="24">
                <div>
                    <el-table :data="tableData" style="width: 100%; margin-top: 20px;"
                        @selection-change="handleSelectionChange">
                        <el-table-column type="selection" width="55">
                        </el-table-column>
                        <el-table-column prop="id" label="流水单号" width="200"></el-table-column>

                        <!-- 客户/用户列 -->
                        <el-table-column label="客户/用户" width="120">
                            <template slot-scope="scope">
                                <span>{{ scope.row.customerId || scope.row.userId }}</span>
                            </template>
                        </el-table-column>

                        <el-table-column prop="DingDanStatus" label="订单状态" width="80">
                            <template slot-scope="scope">
                                <span v-if="scope.row.DingDanStatus == 0" style="color: red;">待审核</span>
                                <span v-else-if="scope.row.DingDanStatus == 1" style="color: #00FF00;">待调度</span>
                                <span v-else-if="scope.row.DingDanStatus == 2" style="color: #00FF00;">运输中</span>
                                <span v-else-if="scope.row.DingDanStatus == 3" style="color: #00FF00;">已签收</span>
                                <span v-else-if="scope.row.DingDanStatus == 4" style="color: #00FF00;">已拒绝</span>
                                <span v-else-if="scope.row.DingDanStatus == 5" style="color: #00FF00;">已取消</span>
                                <span v-else style="color: gray;">未知</span>
                            </template>
                        </el-table-column>

                        <el-table-column prop="jieSuanStatus" label="结算状态" width="100">
                            <template slot-scope="scope">
                                <span v-if="scope.row.jieSuanStatus == 0" style="color: #0f0;">已结算</span>
                                <span v-else-if="scope.row.jieSuanStatus == 1" style="color: red;">未结算</span>
                                <span v-else style="color: gray;">未知</span>
                            </template>
                        </el-table-column>

                        <el-table-column prop="jieSuanTime" label="结算时间" width="100"></el-table-column>

                        <el-table-column prop="duiZhangStatus" label="对账单状态" width="150">
                            <template slot-scope="scope">
                                <span v-if="scope.row.duiZhangStatus == 0" style="color: red;">未对</span>
                                <span v-else-if="scope.row.duiZhangStatus == 1" style="color: #00FF00;">已对</span>
                                <span v-else style="color: gray;">未知</span>
                            </template>
                        </el-table-column>

                        <el-table-column prop="status" label="开票状态" width="100">
                            <template slot-scope="scope">
                                <span v-if="scope.row.status == 0" style="color: red;">未开</span>
                                <span v-else-if="scope.row.status == 1" style="color: #00FF00;">已开</span>
                                <span v-else style="color: gray;">未知</span>
                            </template>
                        </el-table-column>

                        <el-table-column prop="kaipiaoMoney" label="开票金额" width="100"></el-table-column>
                        <el-table-column prop="time" label="开票时间" width="100"></el-table-column>
                        <el-table-column prop="username" label="开票人" width="150"></el-table-column>



<!-- 
                        <el-table-column label="操作" width="200">
                            <template slot-scope="scope">
                                <el-button type="text" size="medium" @click="detailsBtn(scope.row.id)">详情</el-button>
                            </template>
                        </el-table-column> -->
                    </el-table>
                </div>
            </el-col>
        </el-row>


        <el-row>
            <el-col :span="24">
                <!-- 分页部分 -->
                <div>
                    <el-pagination background :page-sizes="[5, 10, 20, 50]" :page-size="pageSize"
                        :current-page="pageNum" layout="total, sizes, prev, pager, next, jumper" :total="total"
                        @prev-click="prePage" @next-click="nextPage" @current-change="curPage"
                        @size-change="sizeChange">
                    </el-pagination>
                </div>
            </el-col>
        </el-row>




        <!-- 详情弹窗 -->
        <el-dialog title="详情" :visible.sync="detailsVisible">
            <el-form>
                <el-form-item label="发票类型" label-width="80px">
                    <el-select placeholder="请选择" style="width: 120px;" v-model="details.fapiaoStatus">
                        <el-option label="普通发票" value="0"></el-option>
                        <el-option label="增值税发票" value="1"></el-option>
                    </el-select>
                </el-form-item>

                <el-form-item label="纳税人识别号" label-width="80px">
                    <el-input v-model="details.shibiehao"></el-input>
                </el-form-item>


                <el-form-item label="开户行" label-width="80px">
                    <el-input v-model="details.kaihuhang"></el-input>
                </el-form-item>

                <el-form-item label="银行卡号" label-width="80px">
                    <el-input v-model="details.kahao"></el-input>
                </el-form-item>

                <el-form-item label="税务服务名称" label-width="80px">
                    <el-input v-model="details.shuiwufuwu"></el-input>
                </el-form-item>

                <el-form-item label="税额合计" label-width="80px">
                    <el-input v-model="details.shui"></el-input>
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="detailsVisible = false">取 消</el-button>
            </div>
        </el-dialog>



    </div>
</template>

<script>
export default {
    data() {
        return {
            pageSize: 10,
            pageNum: 1,
            total: 0,

            tableData: [],//表格对象
            param: {},//查询参数对象
            details: {},

            multipleSelection: [],
            detailsVisible: false,
        }
    },

    methods: {
        addBtn() {
            this.$router.push("/kaipiao");
        },

        queryAll() {
            let pageParam = {};
            pageParam.pageNum = this.pageNum;
            pageParam.pageSize = this.pageSize;
            pageParam.param = this.param;
            this.$axios.post('api/fapiao/queryFapiao', pageParam)
                .then(resp => {
                    console.log(resp.data);
                    if (resp.data.code == 200) {
                        this.tableData = resp.data.data.list;
                        this.total = resp.data.data.total;
                    }

                })
        },

        detailsBtn(id) {

        },

        clearSearch() {
            this.param = {};
            this.queryAll();
        },

        handleSelectionChange(val) {
            //点击复选框的事件val：是选中的对象数组
            this.multipleSelection = val;
        },

        // 点击上一页
        prePage() {
            if (this.pageNum > 1) {
                this.pageNum--;
                this.queryAll(); // 更新数据
            }
        },

        // 点击下一页
        nextPage() {
            if (this.pageNum < Math.ceil(this.total / this.pageSize)) {
                this.pageNum++;
                this.queryAll(); // 更新数据
            }
        },

        // 页码变化
        curPage(pageNum) {
            this.pageNum = pageNum;
            this.queryAll(); // 更新数据
        },

        // 每页显示条数变化
        sizeChange(pageSize) {
            this.pageSize = pageSize;
            this.pageNum = 1; // 每页条数变化时，回到第一页
            this.queryAll(); // 更新数据
        },



    },
    created() {
        this.queryAll();
    }
}
</script>

<style scoped></style>